package com.yuxi.Dao.Impl;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.yuxi.Dao.UserSecurityDao;
import com.yuxi.Entity.TaskDispatch;
import com.yuxi.Entity.UserInfo;
import com.yuxi.Entity.UserSecurity;

@Repository
public class UserSecurityDaoImpl extends BaseDaoImpl<Serializable, Serializable> implements UserSecurityDao {
	
	private Logger logger=LoggerFactory.getLogger(UserSecurityDaoImpl.class);
	public UserSecurityDaoImpl(){
		super(UserSecurity.class);
	}
	
	@Override
	public UserSecurity getAnswerByQuestion(String q,String a) {
		// TODO Auto-generated method stub
		try{
			UserSecurity u=(UserSecurity)super.find("from UserSecurity where userQuertion=? and userAnswer=?", q,a).get(0);
			logger.info("问题:"+u.getQuestion()+" 答案:"+u.getAnswer()+"回答正确");
			return u;
		}catch(Exception e){
			logger.error("密保问题回答失败！！！");
			return null;
		}	
	}

	@Override
	public UserSecurity getAllQuestionByUserd(Integer id) {
		// TODO Auto-generated method stub
		return (UserSecurity) super.get(id);
	}

	@Override
	public void modify(UserSecurity uSecurity) {
		// TODO Auto-generated method stub
		super.update(uSecurity);
	}

	@Override
	public UserSecurity addSecurity(UserSecurity uSecurity) {
		// TODO Auto-generated method stub
		return (UserSecurity) super.addAndReturn(uSecurity);
	}

}
